fix: defer anti-replay window update until after record authentication#79
Merged
algesten merged 4 commits intoalgesten:mainfrom Mar 7, 2026
Merged
Conversation
Split ReplayWindow::check_and_update() into check() (read-only) and update() (mutating), and call update() only after successful decryption. Previously the replay window was advanced before verifying the record's authenticity, allowing an attacker to forge a ciphertext with a far-ahead sequence number, shift the window, and cause legitimate packets to be rejected as replays (DoS). DTLS 1.2 — RFC 6347 §4.1.2.6: "The receive window is updated only if the MAC verification succeeds." DTLS 1.3 — RFC 9147 §4.5.1: "The window MUST NOT be updated due to a received record until that record has been deprotected successfully." Closes algesten#78
68da2c1 to
1853195
Compare
Owner
|
Thank you!!! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
ReplayWindow::check_and_update()intocheck()(read-only) andupdate()(mutating)replay_update()call to after successful decryption in both DTLS 1.2 and 1.3 incoming record pathsRFC References
Test plan
check_does_not_modify_windowandfailed_auth_does_not_advance_windowverify the two-phase behaviorcargo test— 69 tests + 8 doc-tests)Closes #78
Note
Based on #77 (
dtls12branch) to avoid merge conflicts.